package com.ubing.boot.notesforjava.test.juc;

/**
 * @ClassName : testEquals
 * @Description : testEquals
 * @Author : Xxxxx
 * @Date: 2023-03-16 17:08
 */
public class testEquals {

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        //任何对象不等于null，比较是否为同一类型
        if (!(obj instanceof testEquals)) return false;
        //强制类型转换
        testEquals person = (testEquals) obj;
        //比较属性值
        return getName().equals(person.getName());
    }

    @Override
    public int hashCode() {
        return getName().hashCode();
    }
}
